//
//  ReasonTextTableViewCell.m
//  MobileOffice
//
//  Created by jjkj on 16/11/4.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "ReasonTextTableViewCell.h"

@implementation ReasonTextTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier title:(NSString *)title noticeStr:(NSString *)noticeStr{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        if (noticeStr) {
            _noticeStr=[noticeStr copy];
        }
        _myTitleLabel=[MyControl creatLabelWithFrame:CGRectMake(10, 0, IPHONE_WIDTH-30, 20) text:title];
        [_myTitleLabel sizeToFit];
        _myTitleLabel.layer.masksToBounds=YES;
        _myTitleLabel.layer.cornerRadius=3;
        [self.contentView addSubview:_myTitleLabel];
        if (!title) {
            _myTitleLabel.height=0;
        }
        _reasonTextView=[[UITextView alloc]initWithFrame:CGRectMake(10, _myTitleLabel.y+_myTitleLabel.height, IPHONE_WIDTH-20, 80)];
        _reasonTextView.delegate=self;
//        _reasonTextView.layer.borderWidth=1;
//        _reasonTextView.layer.borderColor=[BACKCOLOR_GRAY CGColor];
        _reasonTextView.font=FONT_15;
        if (noticeStr) {
            _reasonTextView.text=noticeStr;
            _reasonTextView.textColor=[UIColor lightGrayColor];
        }
        [self.contentView addSubview:_reasonTextView];
        
//        _lineLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, _reasonTextView.y+_reasonTextView.height-1, IPHONE_WIDTH, 1)];
//        _lineLabel.backgroundColor=BACKCOLOR_GRAY;
//        [self.contentView addSubview:_lineLabel];
    }
    return self;
}

#pragma mark -textViewDelegate
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    if (_noticeStr) {
        if ([textView.text isEqualToString:_noticeStr]) {
            textView.textColor=[UIColor blackColor];
            textView.text=@"";
        }
    }
    return YES;
}

- (BOOL)textViewShouldEndEditing:(UITextView *)textView{
    if (_noticeStr) {
        if (textView.text.length==0) {
            textView.textColor=[UIColor lightGrayColor];
            textView.text=_noticeStr;
        }
    }
    return YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
